Skip to content

Display Header names dynamically - #753

Open
infofromca wants to merge 16 commits into
OrchardCMS:mainfrom
infofromca:DisplayName
Open

infofromca wants to merge 16 commits into
OrchardCMS:mainfrom
infofromca:DisplayName

Conversation

@infofromca

Copy link
Copy Markdown
Contributor

Fix #689
I find a way to show those dynamiclly

@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Please resolve those before requesting a review.

@infofromca

Copy link
Copy Markdown
Contributor Author

@sarahelsaig please review it

@infofromca

Copy link
Copy Markdown
Contributor Author

@sarahelsaig please review it

@infofromca

Copy link
Copy Markdown
Contributor Author

@sarahelsaig
please review it


public static class TableHeaders
{
public static IList<LocalizedHtmlString> GetDefaultHeaders(IHtmlLocalizer htmlLocalizer, HeadersDisplayNamesOptions options) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the first parameter a specific localizer (e.g. IHtmlLocalizer<HeadersDisplayNamesOptions>) to avoid confusion with passing in different translation contexts.


public static class TableHeaders
{
public static IList<LocalizedHtmlString> GetDefaultHeaders(IHtmlLocalizer htmlLocalizer, HeadersDisplayNamesOptions options) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this method called get "default" headers? The values depend on the options, so they aren't default. I think it should be GetLocalizedShoppingCartHeaders.

<div>
<strong>@T["Gross Price: {0}", Model.GrossTotal]</strong>
<strong>@T["{0}: {1}", options.Value.GrossPrice, Model.GrossTotal]</strong>
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options.Value.NetPrice and options.Value.GrossPrice are not localized here. Add a helper to TableHeaders for these, because they recur in other places as well.

Comment on lines +73 to +83
@T["Net Price: {0}", netTotal]
@T["{0}: {1}", options.Value.NetPrice, netTotal]
}
@if (priceDisplaySettings.UseNetPriceDisplay && priceDisplaySettings.UseGrossPriceDisplay)
{
<text>|</text>
}
@if (priceDisplaySettings.UseGrossPriceDisplay)
{
@T["Gross Price: {0}", grossTotal]
@T["{0}: {1}", options.Value.GrossPrice, grossTotal]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be localized as well.

<div class="pb-3 field field-type-pricefield field-name-tax-rate-gross-price"
title="@T["Estimate, the final value is calculated during checkout."]">
<strong class="tax-rate-gross-price-title">@T["Gross Price*:"]</strong>
<strong class="tax-rate-gross-price-title">@T[$"{options.Value.GrossPrice}*:"]</strong>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is invalid. The value of @T[string] must be a compile time constant.

[RequireFeatures(CommerceConstants.Features.HeadersDisplayNames)]
public class PriceDisplayNamesStartup : StartupBase
{
private readonly IShellConfiguration _configuration;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be called _shellConfiguration for consistency.

Comment thread src/Modules/OrchardCore.Commerce/Startup.cs Outdated
Comment thread src/OrchardCore.Commerce.Web/appsettings.json Outdated
Comment on lines +4 to +6
namespace OrchardCore.Commerce.Abstractions.Extensions;

public static class TableHeaders

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method in this class is not an extension method so this is the wrong place. Also it's more related to localization than tables. So please move this to src/Libraries/OrchardCore.Commerce.Abstractions/Helpers/ and rename the class to LocalizationHelpers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The name of Gross Price is a little confused (OCC-411)

2 participants